//
//  MiningVC.m
//  ShandsMod
//
//  Created by zh_s on 2023/3/22.
//  Copyright © 2023 zh_s. All rights reserved.
//

#import "MiningVC.h"
#import "MiningTotalNumCell.h"
#import "TestDateCell.h"
#import "TestAddressHeaderV.h"
#import "TestAddressFotterV.h"
#import "TestMiningAddressListCell.h"

@interface MiningVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *mainTableView;
@property (nonatomic, strong) NSArray *dataArr;

@end

@implementation MiningVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.nav.hidden = YES;
    self.view.backgroundColor = BASE_BACKCOLOR;
    [self data_init];
    [self UI_init];
    // Do any additional setup after loading the view.
}

#pragma mark ----- UI_init
- (void)UI_init {
    [self.view addSubview:self.mainTableView];
    
    UIView *footerV = [BaseViewFactory viewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 73) color:UIColor.clearColor];
    UIButton *getReward = [BaseViewFactory buttonWithFrame:CGRectZero font:FONT_NAME(FONT_Semibold, 16) title:@"一键领取" titleColor:MAIN_ACTIVE_COLOR backColor:UIColor.clearColor];
    [footerV addSubview:getReward];
    [getReward mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(footerV.mas_centerX);
        make.top.mas_equalTo(16);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 70, 40));
    }];
    GWRadius(getReward, 20);
    getReward.layer.borderColor = MAIN_ACTIVE_COLOR.CGColor;
    getReward.layer.borderWidth = 1.f;
    [getReward addTarget:self action:@selector(getRewardClick) forControlEvents:UIControlEventTouchUpInside];
    self.mainTableView.tableFooterView = footerV;
}
#pragma mark ----- data_init
- (void)data_init {
    _dataArr = @[@"111",@"2222",@"231231",@"4234123",@"1231254213",@"hjksad",@"123123",@"111",@"2222",@"231231",@"4234123",@"1231254213",@"hjksad",@"123123"];
}
#pragma mark ----- tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 2) {
        return _dataArr.count;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {

        MiningTotalNumCell *walletCell = [tableView dequeueReusableCellWithIdentifier:@"walletCell" forIndexPath:indexPath];
        return walletCell;
    }else if (indexPath.section == 1) {
        TestDateCell *dateCell = [tableView dequeueReusableCellWithIdentifier:@"dateCell" forIndexPath:indexPath];
        return dateCell;
    }else {
        TestMiningAddressListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
        cell.titleLab.text = self.dataArr[indexPath.row];
        cell.subtitleLab.text = self.dataArr[indexPath.row];
        return cell;
    }
  
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 2) {
        return 25;
    }
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 15;
    }else if (section == 2) {
        return 56;
    }
    return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (section == 2) {
        TestAddressFotterV *fotterV = [[TestAddressFotterV alloc] init];
        fotterV.frame = CGRectMake(0, 0, SCREEN_WIDTH, 25);
        return fotterV;
    }
    return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        TestAddressHeaderV *headerV = [[TestAddressHeaderV alloc] init];
        headerV.frame = CGRectMake(0, 0, SCREEN_WIDTH, 56);
        return headerV;
        
    }
    return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 155;
    }else if (indexPath.section == 1) {
        return 80;
    }
    return 30;
}

#pragma mark ----- 点击事件
- (void)getRewardClick {
    SHOW_TIPS(@"领取奖励");
}

#pragma mark ----- 懒加载
- (UITableView *)mainTableView {
    if (!_mainTableView) {
        _mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT -NAV_HEIGHT - CUSTOM_TABBAR_HEIGHT) style:UITableViewStyleGrouped];
        _mainTableView.delegate = self;
        _mainTableView.dataSource = self;
        _mainTableView.showsVerticalScrollIndicator = NO;
        _mainTableView.rowHeight = 100;
        _mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
        _mainTableView.backgroundColor = BASE_BACKCOLOR;
        [_mainTableView registerClass: [TestMiningAddressListCell class] forCellReuseIdentifier:@"cell"];
        [_mainTableView registerClass:[MiningTotalNumCell class] forCellReuseIdentifier:@"walletCell"];
        [_mainTableView registerClass:[TestDateCell class] forCellReuseIdentifier:@"dateCell"];
    }
    return _mainTableView;
}

@end
